package com.mk.legoscans2.data;

import java.util.HashMap;
import java.util.Map;

import android.graphics.Bitmap;

public class CachingThumbnailService implements ThumbnailService{

	ThumbnailService _inner;
	private Map<String, Bitmap> _cache = new HashMap<String, Bitmap>();
	
	public CachingThumbnailService(ThumbnailService inner)
	{
		_inner = inner;
	}
	
	public Bitmap getThumbnail(String scanId) {
		if(!_cache.containsKey(scanId))
		{
			Bitmap bmp = _inner.getThumbnail(scanId);
			if(bmp == null)
				return null;
			_cache.put(scanId, bmp);
		}
		
		return _cache.get(scanId);
	}

}
